package org.example.blogserver.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.example.blogserver.service.ArticleService;
import org.example.blogserver.service.CommentsService;
import org.example.blogserver.vo.Result;
import org.example.blogserver.vo.params.ArticleIdParam;
import org.example.blogserver.vo.params.ArticleParam;
import org.example.blogserver.vo.params.CommentParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("edit")
public class EditController {
    @Autowired
    private CommentsService commentsService;
    @Autowired
    private ArticleService articleService;
    @Autowired
    private ObjectMapper objectMapper;
    @PostMapping("/add")
    public Result addArticle(@RequestBody ArticleParam articleParam, @RequestHeader String token){
        return articleService.addArticle(token,articleParam);
    }
    @PostMapping("/modify")
    public Result modifyArticle(@RequestBody ArticleIdParam articleIdParam, @RequestHeader String token) {
        return articleService.updateArticle(token, articleIdParam);
    }

}
